<?php

/**
 * Doctor form base class.
 *
 * @package    form
 * @subpackage doctor
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 8508 2008-04-17 17:39:15Z fabien $
 */
class BaseDoctorForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                     => new sfWidgetFormInputHidden(),
      'especialidad_doctor_id' => new sfWidgetFormDoctrineChoice(array('model' => 'EspecialidadDoctor', 'add_empty' => false)),
      'perfil_id'              => new sfWidgetFormDoctrineChoice(array('model' => 'Perfil', 'add_empty' => false)),
      'dni'                    => new sfWidgetFormInput(),
      'codigo_colegiatura'     => new sfWidgetFormInput(),
      'nombres'                => new sfWidgetFormInput(),
      'apellido_paterno'       => new sfWidgetFormInput(),
      'apellido_materno'       => new sfWidgetFormInput(),
      'fecha_nacimiento'       => new sfWidgetFormDate(),
      'sexo'                   => new sfWidgetFormInput(),
      'estado'                 => new sfWidgetFormInput(),
      'slug'                   => new sfWidgetFormInput(),
      'created_at'             => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'                     => new sfValidatorDoctrineChoice(array('model' => 'Doctor', 'column' => 'id', 'required' => false)),
      'especialidad_doctor_id' => new sfValidatorDoctrineChoice(array('model' => 'EspecialidadDoctor')),
      'perfil_id'              => new sfValidatorDoctrineChoice(array('model' => 'Perfil')),
      'dni'                    => new sfValidatorString(array('max_length' => 8)),
      'codigo_colegiatura'     => new sfValidatorString(array('max_length' => 5)),
      'nombres'                => new sfValidatorString(array('max_length' => 100)),
      'apellido_paterno'       => new sfValidatorString(array('max_length' => 100)),
      'apellido_materno'       => new sfValidatorString(array('max_length' => 100)),
      'fecha_nacimiento'       => new sfValidatorDate(array('required' => false)),
      'sexo'                   => new sfValidatorString(array('max_length' => 1)),
      'estado'                 => new sfValidatorString(array('max_length' => 1)),
      'slug'                   => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'created_at'             => new sfValidatorDateTime(array('required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'Doctor', 'column' => array('slug')))
    );

    $this->widgetSchema->setNameFormat('doctor[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Doctor';
  }

}
